/**
 * @description 存放变量的hook
 * @author fzl
 */

import { reactive, ref, getCurrentInstance } from "vue";

interface IRuleForm {
    mobile: string;
    password: string;
}


/**
 * @param t useI18n()国际化配置的翻译方法
 */
export default function useFormProperties(t: any) {

    const activeName = ref("login");
    const ruleFormRef = ref();
    const loginText = ref(t("login.loginBtn"));
    const ruleForm: IRuleForm = reactive({
        mobile: "",
        password: ""
    });

    // * 表单校验规则
    const rules = reactive({
        mobile: [
            {
                required: true,
                min: 5,
                max: 11,
                message: t("login.placeMobile"),
                trigger: "blur"
            }
        ],
        password: [
            {
                required: true,
                min: 5,
                max: 11,
                message: t("login.placePass"),
                trigger: "blur"
            }
        ]
    })
    return {
        activeName,
        loginText,
        ruleFormRef,
        ruleForm
    }

}

